<?php include('../includes/mysqli_connect.php');?>
<?php include('../includes/function.php');?>
<?php
    if(isset($_GET['cid'])&& filter_var($_GET['cid'],FILTER_VALIDATE_INT,array('min_range'=>1)))
    {
        $cid=$_GET['cid'];
        $q="Delete from categories where cat_id={$cid}";
        $r=mysqli_query($dbc,$q);
        confirm_query($r,$q);
       if(mysqli_affected_rows($r)==1){
        echo "<script lang='javascript'>alert('The category has been delete');</script>";
       }
        redirect_to('admin/view_categories.php');
    }
    else{
        redirect_to('admin/view_categories.php');
    }
?>